﻿@{
    Layout = null;
    var plugName = @news.admin.cyt369.com.Areas.NewsAdmin.Models.PlugName.Name;
    var tableName = PageViewModel.PageTableID(this, plugName);
    var tableToolBar = PageViewModel.PageTableToolbar(this, plugName);
    var tableToolBarSearch = PageViewModel.PageTableToolbarSearch(this);
    var tableToolBarReset = PageViewModel.PageTableToolbarReset(this);
    var deleteFunName = PageViewModel.PageFunctionName(this, "delete_doc");

    var auditFunName = PageViewModel.PageFunctionName(this, "audit_article", plugName);
    var auditDlgName = PageViewModel.PageEditDialog(this, "audit", plugName);

    var auditLogFunName = PageViewModel.PageFunctionName(this, "view_audit_log", plugName);
    var auditLogDlgName = PageViewModel.PageEditDialog(this, "audit_log_dlg", plugName);

    var viewFunName = PageViewModel.PageFunctionName(this, "view_article", plugName);
    var viewDlgName = PageViewModel.PageEditDialog(this, "view", plugName);

    var titleFmtFun = PageViewModel.PageFunctionName(this, "title_fmt", plugName);
    var auditLogFmtFun = PageViewModel.PageFunctionName(this, "audit_log_fmt", plugName);
    var contentTypeFmtFun = PageViewModel.PageFunctionName(this, "ContentType_fmt", plugName);
    var documentTypeIDFmtFun = PageViewModel.PageFunctionName(this, "DocumentTypeID_fmt", plugName);
    var contentSourceIDFmtFun = PageViewModel.PageFunctionName(this, "ContentSourceID_fmt", plugName);
}
<div style="height:100%">
    <script type="text/javascript">
        function @auditFunName (id) {
            var dlg = $dlg('@auditDlgName');
            dlg.dialog({
                title: '文章审核', width: 1000, height: 600,
                closed: false, cache: false, modal: true, maximizable: true, resizable: true, maximized:true,
                href: '~/@plugName/Articles/_AuditArticleDlg/'+id+'?dlg=@auditDlgName',
                onResize: function () {
                    $(this).dialog('center');
                },
                onClose: function () {
                    $('#@tableName').datagrid('reload');
                }
            });
        }

        function @viewFunName (id) {
            var dlg = $dlg('@viewDlgName');
            dlg.dialog({
                title: '内容预览', width: 1000, height: 600,
                closed: false, cache: false, modal: true, maximizable: true, resizable: true, maximized:true,
                href: '~/@plugName/Articles/_ViewArticleDlg/'+id+'?dlg=@viewDlgName',
                onResize: function () {
                    $(this).dialog('center');
                }
            });
        }

        function @auditLogFunName (id) {
            var dlg = $dlg('@auditLogDlgName');
            dlg.dialog({
                title: '审核记录', width: 1000, height: 600,
                closed: false, cache: false, modal: true, maximizable: true, resizable: true, maximized:false,
                href: '~/@plugName/Articles/_AuditLogDlg/'+id+'?dlg=@auditLogDlgName',
                onResize: function () {
                    $(this).dialog('center');
                }
            });
        }
    </script>

    <script type="text/javascript">
        function @tableToolBarSearch {
            $('#@tableName').datagrid('load', {
                Title: $("#@tableToolBar").find("#_Title").textbox("getValue"),
            });
        }

        function @tableToolBarReset {
            $("#@tableToolBar").find("#_Title").textbox("setValue", "");
            @tableToolBarSearch ();
        }
    </script>

    <script type="text/javascript">
        function @deleteFunName (id) {
            if (id > 0 && confirm("确认删除内容?")) {
                $.ajax({
                    async: false,
                    method: "DELETE",
                    url: $.Content("~/@plugName/Articles/DeleteDocument/" + id),
                    context: $("#@tableName"),
                    success: function (e) {
                        if (e.Result) {
                            this.datagrid('reload');
                        } else {
                            $.messager.alert('删除数据', '删除失败: ' + e.Msg, 'error');
                        }
                    },
                    error: function (e1, e2, e3) {
                        ShowAjaxError(e1, "删除数据");
                        this.datagrid('reload');
                    }
                });
            }
        }

        function @titleFmtFun (v, r, i) {
            return "<a href='javascript:@viewFunName (" + r.Id + ")'>" + v + "</a>";
        }

        function @auditLogFmtFun (v, r, i) {
            return "<a href='javascript:@auditLogFunName (" + r.Id + ")'>审核记录</a>";
        }

        function @documentTypeIDFmtFun (v, r, i) {
            var v = GetObject(v, '~/@plugName/DocTypes/GetDocumentTypeByID');
            if (v != null) { return v.Name; }
        }

        function @contentTypeFmtFun (v, r, i) {
            switch (v) {
                case 1:
                    return "文本";
                case 2:
                    return "视频";
                case 3:
                    return "图集";
            }
        }

        function @contentSourceIDFmtFun (v,r,i) {
            switch (v) {
                case 1:
                    return "原创";
                case 2:
                    return "转载";
                case 3:
                    return "翻译";
            }
        }
    </script>

    <table id="@tableName" class="easyui-datagrid" style="width:100%;" rownumbers="true" fit="true"
           pagination="true" pageSize="@SystemSettingService.Instance.PageSize" pageList="@SystemSettingService.Instance.PageList"
           data-options="striped:true,border:false,singleSelect:true,url:'~/@plugName/Articles/GetArticles?AuditStatus=10',method:'get',toolbar:'#@tableToolBar'">
        <thead>
            <tr>
                <th data-options="field:'_remove',align:'center',formatter:function(v,r,i){
                        return GridRowDeleteFmt('@deleteFunName', r.Id);
                    }" width="45">删除</th>
                <th data-options="field:'_audit',align:'center',formatter:function(v,r,i){
                    return GridRowAuditFmt('@auditFunName', r.Id);
                }" width="45">审核</th>
                <th data-options="field:'_auditLog',align:'center',formatter:@auditLogFmtFun" width="80">审核记录</th>
                <th data-options="field:'ContentType',align:'center',formatter:@contentTypeFmtFun" width="80">栏目</th>
                <th data-options="field:'DocumentTypeID',align:'center',formatter:@documentTypeIDFmtFun" width="80">类型</th>
                <th data-options="field:'ContentSourceID',align:'center',formatter:@contentSourceIDFmtFun" width="60">创作</th>
                <th data-options="field:'Title',formatter:@titleFmtFun" width="300">标题</th>
                <th data-options="field:'Read',align:'center'" width="80">阅读量</th>
                <th data-options="field:'Great',align:'center'" width="80">点赞量</th>
                <th data-options="field:'Author'" width="100">作者</th>
                <th data-options="field:'EditorName'" width="100">编辑</th>
                <th data-options="field:'EditorFullName'" width="100">编辑姓名</th>
                <th data-options="field:'CanComment',align:'center',formatter:$.CheckdFormat" width="70">允许评论</th>
                <th data-options="field:'IsAds',align:'center',formatter:$.CheckdFormat" width="70">是否广告</th>
                <th data-options="field:'GotoTarget',align:'center',formatter:$.CheckdFormat" width="70">跳转来源</th>
                <th data-options="field:'TargetURL'" width="150">原文来源</th>
                <th data-options="field:'CreatedTime',align:'center',formatter:$.DateTimeFmt" width="150">创建时间</th>
                <th data-options="field:'ChangedTime',align:'center',formatter:$.DateTimeFmt" width="150">修改时间</th>
            </tr>
        </thead>
    </table>
    <div id="@tableToolBar" class="table-toolbar">
        <ul class="query-body">
            <li>
                <span>标题：</span>
                <input id="_Title" class="easyui-textbox" />
            </li>
            <li>
                <a href="javascript:@tableToolBarSearch" class="easyui-linkbutton" data-options="iconCls:'icon-search'">查询</a>
                <a href="javascript:@tableToolBarReset" class="easyui-linkbutton" data-options="iconCls:'icon-reload'">重置</a>
            </li>
        </ul>
    </div>
</div>
